package com.dc.refactoring._4_简化条件表达式._6_ReplaceConditionalWithPolymorphism.oldProject;

import lombok.Data;

/**
 * Description: 以多态取代条件表达式_雇员类
 * @author: gdc
 * @date: 2020/12/6
 * @version 1.0
 */
@Data
public class Employee {
    public static final int MANAGER = 0;

    public static final int ENGINEER = 1;

    public static final int SALESMAN = 2;

    private int type;

    private double base;

    /**
     * 获取金额
     */
    public double getAmount(){
        switch (getType()){
            case MANAGER: return base * 100;
            case ENGINEER: return base * 0.8;
            case SALESMAN: return base * 1;
            default: throw new RuntimeException("not find Employee type");
        }
    }
}
